axios.interceptors.response.use(function (response) {
    var url = response.config.url;
    if (url.indexOf("kcsapi") > -1) {
        var event = new CustomEvent("KCEEvent", {
            "detail": {
                "type": 'KCE_MSG',
                "url": response.config.url,
                "data": response.data
            }
        });
        fireCustomEvent(event);
    }
    return response;
}, function (error) {
    return Promise.reject(error);
});

function fireCustomEvent(event) {
    var hiddenDiv = document.getElementById('KCEEventDiv');
    hiddenDiv.dispatchEvent(event);
}